﻿using FOModels.Customer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bussiness.Customer;
using FOSystem.CultureHelper;
namespace FO.Controllers
{
    public class CustomerController : CultureController
    {
        //
        // GET: /Customer/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult ThanksYou()
        {
            return View();
        }
        [HttpPost]
        public ActionResult SearchCustomerbyEmail(string email)
        {
            CustomerBLL bll = new CustomerBLL();
            CustomerModels cus = new CustomerModels();
            cus = bll.SearchCustomerbyEmail(email);
            if (cus == null)
            {
                return Json(null);
            }
            else
            {
                return Json(cus);
            }
       
        }
        [HttpPost]
        public ActionResult InsertCustomer(string customername, string email, string phone, string address, string dob, string incoming)
        {
            CustomerBLL bll = new CustomerBLL();
            CustomerModels cus = new CustomerModels();
            cus.CustomerName = customername;
            cus.Email = email;
            cus.Phone = phone;
            cus.Address = address;
            cus.DOB = dob;
            cus.InComing = incoming;
            int check = bll.InsertCustomer(cus);
            return Json(check);
        }
        [HttpPost]
        public ActionResult UpdateCustomerInfo(string customername, string email, string phone, string address, string dob, string incoming)
        {
            CustomerBLL bll = new CustomerBLL();
            CustomerModels cus = new CustomerModels();
            cus.CustomerName = customername;
            cus.Email = email;
            cus.Phone = phone;
            cus.Address = address;
            cus.DOB = dob;
            cus.InComing = incoming;
            int check = bll.UpdateCustomerInfo(cus);
            return Json(check);
        }
        [HttpPost]
        public ActionResult Top1Customer()
        {
            CustomerBLL bll = new CustomerBLL();
            CustomerModels cus = new CustomerModels();
            cus = bll.Top1Customer();
            return Json(cus);
        }

    }
}
